<?php
namespace App\Model;

use PhalApi\Model\NotORMModel as NotORM;

class Member extends NotORM {

    //设置表名
    protected function getTableName($id) {
        return 'users';
    }

    // 按条件获取用户信息
    public function getUserInfo( $openid ) {
        return $this->getORM()
            ->select('user_id,head_pic,mobile,nickname,openid')
            ->where( array( 'openid' => $openid ) )
            ->fetchOne();
    }

    // 添加用户信息
    public function insertUserInfo( $wx_info ) {
        $this->getORM()->insert( $wx_info );
        return $this->getORM()->insert_id();
    }

    // 按条件获取用户信息
    public function getUserPic( $user_id ) {
        return $this->getORM()
            ->select('user_id,head_pic,mobile,nickname,openid')
            ->where( array( 'user_id' => $user_id ) )
            ->fetchOne();
    }
}
